#coding:utf-8
'''
Created on 2013-1-28

@author: edsion
'''
import win32com.client 
def encrypt(key,content): # key:密钥,content:明文 
    EncryptedData = win32com.client.Dispatch('CAPICOM.EncryptedData') 
    EncryptedData.Algorithm.KeyLength = 5 
    EncryptedData.Algorithm.Name = 2 
    EncryptedData.SetSecret(key) 
    EncryptedData.Content = content 
    return EncryptedData.Encrypt() 
 
def decrypt(key,content): # key:密钥,content:密文 
    EncryptedData = win32com.client.Dispatch('CAPICOM.EncryptedData') 
    EncryptedData.Algorithm.KeyLength = 5 
    EncryptedData.Algorithm.Name = 2 
    EncryptedData.SetSecret(key) 
    EncryptedData.Decrypt(content) 
    str = EncryptedData.Content 
    return str 
 
#s1 = encrypt('wOwdmdlm200201058', 'z200201058') 
#s2 = decrypt('wOwdmdlm200201058', s1) 
#print s1 +"====\n" + s2 


#======================
#方法2
import base64 
 
s1 = base64.encodestring('edsion@21kunpeng.com') 
s2 = base64.decodestring(s1) 
print s1,s2 